package com.zy.openchat.core.model.photo;

import android.os.Parcel;
import android.os.Parcelable;

import com.zy.openchat.core.model.file.FileInfo;

public class PhotoSizeInfo implements Parcelable {
    //s\m\i\x\y
    public String type;
    public float width;
    public float height;
    public FileInfo photo;

    public boolean isPhotoDownloaded() {
        if (photo != null && photo.local != null && photo.local.isExist()) {
            return true;
        }
        return false;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.type);
        dest.writeFloat(this.width);
        dest.writeFloat(this.height);
        dest.writeParcelable(this.photo, flags);
    }

    public PhotoSizeInfo() {
    }

    protected PhotoSizeInfo(Parcel in) {
        this.type = in.readString();
        this.width = in.readFloat();
        this.height = in.readFloat();
        this.photo = in.readParcelable(FileInfo.class.getClassLoader());
    }

    public static final Creator<PhotoSizeInfo> CREATOR = new Creator<PhotoSizeInfo>() {
        @Override
        public PhotoSizeInfo createFromParcel(Parcel source) {
            return new PhotoSizeInfo(source);
        }

        @Override
        public PhotoSizeInfo[] newArray(int size) {
            return new PhotoSizeInfo[size];
        }
    };
}
